﻿using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace Fast
{
    public static class ConfigureContextServiceCollectionExtensions
    {
        public static IApplicationBuilder GetApplicationBuilder(this ConfigureContext context)
        {
            return context.ServiceProvider.GetRequiredService<IApplicationBuilder>();
        }

        public static IWebHostEnvironment GetEnvironment(this ConfigureContext context)
        {
            return context.ServiceProvider.GetRequiredService<IWebHostEnvironment>();
        }

        public static IWebHostEnvironment GetEnvironmentOrNull(this ConfigureContext context)
        {
            return context.ServiceProvider.GetService<IWebHostEnvironment>();
        }

        public static IConfiguration GetConfiguration(this ConfigureContext context)
        {
            return context.ServiceProvider.GetRequiredService<IConfiguration>();
        }

        public static ILoggerFactory GetLoggerFactory(this ConfigureContext context)
        {
            return context.ServiceProvider.GetRequiredService<ILoggerFactory>();
        }
    }
}
